package com.aiwiown.snackmq.console.web;

import com.aiwiown.snackmq.console.service.SnackMQAdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
@RequestMapping("/groups")
public class ConsumerGroupController {

    @Autowired
    private SnackMQAdminService adminService;
    @GetMapping
    public String listConsumerGroups(Model model) {
        try {
            model.addAttribute("groups", adminService.listConsumerGroups());
        } catch (Exception e) {
            model.addAttribute("error", "Failed to fetch consumer group list: " + e.getMessage());
        }
        return "groups"; // 对应 groups.html
    }
}